#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int abs(int a)
    {
        return a > 0 ? a : -a;
    }
    int findClosestNumber(vector<int>& nums) {
        int res = INT_MAX;
        for (auto& e : nums)
        {
            int a = abs(e), b = abs(res);
            if (a < b)
                res = e;
            else if (a == b)
                res = max(e, res);
        }
        return res;
    }
};